常見的幾款虛機(jī)偽靜態(tài)配置方法
偽靜態(tài)配置
標(biāo)簽作用:配置程序偽靜態(tài)后URL中將不再包含兼容模式的問號(hào),整個(gè)地址更美觀,也便于推廣優(yōu)化。
適用版本:2.X 、3.X
1、IIS7+環(huán)境(IIS6的環(huán)境自行百度):
1)安裝rewrite組件,如果使用空間一般空間商默認(rèn)已經(jīng)安裝;
2)到后臺(tái)配置參數(shù)中開啟偽靜態(tài)開關(guān);
3)在站點(diǎn)目錄建立web.config文件(可到源碼包rewrite目錄下拷貝規(guī)則),規(guī)則內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="reIndex" stopProcessing="true"> <match url="^(.*)$" ignoreCase="true" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="index.php?p={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
2、Apache環(huán)境
1)開啟Apache重寫模塊,具體請(qǐng)百度,如果使用空間一般空間商默認(rèn)已經(jīng)開啟;
2)到后臺(tái)配置參數(shù)中開啟偽靜態(tài)開關(guān);
3)在站點(diǎn)目錄建立.htaccess文件(可到源碼包rewrite目錄下拷貝規(guī)則),規(guī)則內(nèi)容如下:
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?p=$1 [QSA,PT,L] </IfModule>
3、Nginx環(huán)境
1、到后臺(tái)配置參數(shù)中開啟偽靜態(tài);
2、在nginx虛擬主機(jī)location配置中添加規(guī)則,規(guī)則如下:
location / { if (!-e $request_filename){ rewrite ^/index.php(.*)$ /index.php?p=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; } }
注意:Nginx中如果站點(diǎn)部署在二級(jí)目錄,請(qǐng)對(duì)應(yīng)修改重寫規(guī)則, 如:二級(jí)目錄為test則:rewrite ^/test/(.*)$ /test/index.php?p=$1 last;
文章轉(zhuǎn)載自:https://www.pbootcms.com/docs/239.html